#include "StockStrategy.h"

#include <gtest/gtest.h>


USING_STOCK_NS

TEST(StockStrategy, GIVEN_Prices_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1,2,3,1,3 };
	strategy.SetPrices(prices);

	strategy.Calc();

    EXPECT_EQ(3, strategy.GetMaxProfit());
	EXPECT_EQ("buy,sell,cooldown,buy,sell", strategy.GetTransactions());
}

TEST(StockStrategy, GIVEN_Prices_None_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{  };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(0, strategy.GetMaxProfit());
	EXPECT_STREQ("pass", strategy.GetTransactions().c_str());
}

TEST(StockStrategy, GIVEN_Prices_1_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(0, strategy.GetMaxProfit());
	EXPECT_STREQ("pass", strategy.GetTransactions().c_str());
}

TEST(StockStrategy, GIVEN_Prices_1_2_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1, 2 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(1, strategy.GetMaxProfit());
	EXPECT_STREQ("buy,sell", strategy.GetTransactions().c_str());
}

TEST(StockStrategy, GIVEN_Prices_1_2_3_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1, 2, 3 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(2, strategy.GetMaxProfit());
	EXPECT_STREQ("buy,pass,sell", strategy.GetTransactions().c_str());
}

TEST(StockStrategy, GIVEN_Prices_1_2_3_4_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1, 2, 3, 4 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(3, strategy.GetMaxProfit());
	EXPECT_STREQ("buy,pass,pass,sell", strategy.GetTransactions().c_str());
}

TEST(StockStrategy, GIVEN_Prices_1_2_3_4_4_4_4_4_4_4_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1, 2, 3, 4, 4, 4, 4, 4, 4, 4 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(3, strategy.GetMaxProfit());
	EXPECT_STREQ("buy,pass,pass,sell", strategy.GetTransactions().c_str());
}
#if 0
TEST(StockStrategy, GIVEN_Prices_1_2_3_4_4_4_4_4_4_4_4_4_4_4_4_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(3, strategy.GetMaxProfit());
	EXPECT_STREQ("buy,pass,pass,sell", strategy.GetTransactions().c_str());
}

TEST(StockStrategy, GIVEN_Prices_1_2_3_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(3, strategy.GetMaxProfit());
	EXPECT_STREQ("buy,pass,pass,sell", strategy.GetTransactions().c_str());
}

TEST(StockStrategy, GIVEN_Prices_1_2_3_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_4_WHEN_CalcMaxProfit_THEN_GetMaxProfitAndTransactions)
{
	StockStrategy  strategy;
	std::vector<float> prices = std::initializer_list<float>{ 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 };
	strategy.SetPrices(prices);

	strategy.Calc();

	EXPECT_EQ(3, strategy.GetMaxProfit());
	EXPECT_STREQ("buy,pass,pass,sell", strategy.GetTransactions().c_str());
}

#endif



